﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            jy3();
        }
        static void jy()
        {
            //用户输入正方形边长，用* 打印出实心正方形。

            //如：用户输入5，则输出如下图形。
            //*****
            //*****
            //*****
            //*****
            //*****
            //Console.WriteLine("请输入正方形的边长");
            //int sc = int.Parse(Console.ReadLine());
            //for (int i = 0; i < sc; i++)
            //{
            //    for (int j = 0; j < sc; j++)
            //    {
            //        Console.Write("* ");
            //    }
            //    Console.WriteLine(" ");
            //}

            Console.WriteLine("请输入正方形的边长");
            int a = int.Parse(Console.ReadLine());
            string[,] arr = new string[a, a];

            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    arr[i, j] = " * ";

                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    Console.Write(arr[i, j]);
                }
                Console.WriteLine();
            }


        }
        static void jy1()
        {
            string[,] sc = new string[9, 9];
            for (int i = 0; i < sc.GetLength(0); i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    sc[i, j] = (i + 1) + " * " + (j + 1) + " = " + (i + 1) * (j + 1) + "\t";
                }
            }
            for (int i = 0; i < sc.GetLength(0); i++)
            {
                for (int j = 0; j < sc.GetLength(1); j++)
                {
                    Console.Write(sc[i, j]);
                }
                Console.WriteLine();
            }
        }
        static void jy2()
        {
            //用户输入正方形边长，用* 打印出空心正方形。

            //如：用户输入5，则输出如下图形。
            //*****
            //*   *
            //*   *
            //*   *
            //*****
            Console.WriteLine("请输入正方形的边长");
            int a = int.Parse(Console.ReadLine());
            string[,] sc = new string[a, a];
            for (int i = 0; i < sc.GetLength(0); i++)
            {
                for (int j = 0; j < sc.GetLength(1); j++)
                {
                    if (i == 0 || i == sc.GetLength(0) - 1)
                    {
                        sc[i, j] = "*";
                    }
                    else if (j == 0 || j == sc.GetLength(1) - 1)
                    {
                        sc[i, j] = "*";
                    }
                    else {
                        sc[i, j] = " ";
                    }

                }
            }
            for (int i = 0; i < sc.GetLength(0); i++)
            {
                for (int j = 0; j < sc.GetLength(1); j++)
                {
                        Console.Write(sc[i, j]);
                }
                Console.WriteLine();
            }
        }
        static void jy3() {
            //  *
            // ***
            //*****
            // ***
            //  *
            //边长是3
            //行列数就是5
            Console.WriteLine("请输入菱形的边长");
            int a = int.Parse(Console.ReadLine());
            string [,] sc = new string[2*a-1, 2*a-1];
            for (int i = 0; i < sc.GetLength(0); i++)
            {
                for (int j = 0; j < sc.GetLength(1); j++)
                {
                     if(i<=a-1&&j<=a-1+i&&j>=a-1-i)
                    {

                        sc[i, j] = "*";
                    }
                    else if( i>=a&&j>=i-a+1&&j<=2*a-1-(i-a+2))
                    {

                        sc[i, j] = "*";
                    }
                    else
                    {
                        sc[i, j] = " ";
                    }
                   

                }
            }
            for (int i = 0; i < sc.GetLength(0); i++)
            {
                for (int j = 0; j < sc.GetLength(1); j++)
                {
                    Console.Write(sc[i, j]);
                }
                Console.WriteLine();
            }

        }

        static void jy4()
        {
            //如果一个数组保存元素是有序的（从大到小），
            //向这个数组中插入一个数，使得插入后的数组元素仍然保持有序。

            int[] arr = new int[6];
            arr[0] = 95;
            arr[1] = 80;
            arr[2] = 70;
            arr[3] = 56;
            arr[4] = 21;

            Console.Write("原数组：");
            for (int i = 0; i < arr.Length; i++)
            {
                if (i == 5)
                {

                }
                else
                {
                    Console.Write(arr[i] + " ");
                }


            }
            Console.WriteLine();
            Console.WriteLine("请输入一个数：");
            int a = int.Parse(Console.ReadLine());
            arr[5] = a;

            Array.Sort(arr);
            Array.Reverse(arr);
            Console.WriteLine("排序后: ");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i] + " ");
            }

        }

        static void jy5()
        {

            //在 Main 方法中创建一个字符串类型的数组，并存入 5 个值，然后将数组中下标是偶数的元素输出。
            int[] arr = { 3, 90, 6, 85, 4 };
            int[] a = new int[5];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                if (arr[i] % 2 == 0)
                {
                    a[i] = arr[i];
                    Console.WriteLine(a[i]);
                }
            }
        }
    }
}
